package imp.core.data.songdata;

import imp.core.basics.date.Date;


/**
 * The class for representing songs.
 * @author Patrick Arnold
 * @since 08.09.2010
 *
 */
public class Song {

	/** The id of the song (must be unique and can never be assigned again). */
	private long id;
	
	/** The file name of the song. */
	private String filename;
	
	/** The title of the song. */
	private String title;
	
	/** The interpret of the song. */
	private String interpret;
	
	/** The year when the song was published (0 if the year is not specified). */
	private int year;
	
	/** The rating of the song (must be a value between 0 and 5.0). */
	private double rating;
	
	/** The tags of the song. */
	private String[] tags;
	
	/** The length of the song (in seconds). */
	private int length;
	
	/** The registration date of the song. */
	private Date registrationDate;
	
	/** The date when the song was played last. */
	private Date lastPlayed;
	
	/** Specified how often the song was already played. */
	private int numberOfPlayings;
	
	/** The annotations of the song. */
	private String annotations;
	
	/** The language key of the song. */
	private String language;
	
	/** The category of the song. */
	private String category;
	
	/** The lyrics of the song. */
	private StringBuffer lyrics;

	
	
	/**
	 * Constructor - Creates a new song object.
	 * @param id The id of the song.
	 * @param filename The file name of the song.
	 * @param title The title of the song.
	 * @param interpret The interpret of the song.
	 * @param year The year when the song was published.
	 * @param rating The rating of the song.
	 * @param tags The tags of the song.
	 * @param length The length of the song.
	 * @param registrationDate The registration date of the song.
	 * @param lastPlayed The date when the song was last played.
	 * @param numberOfPlayings The number of playings of the song.
	 * @param annotations The annotations of the song.
	 * @param language The language of the song.
	 * @param category The category of the song.
	 * @param lyrics The lyrics of the song.
	 */
	public Song( long id, String filename, String title, String interpret, int year, double rating,
			String[] tags, int length, Date registrationDate, Date lastPlayed,
			int numberOfPlayings, String annotations, String language, String category,
			StringBuffer lyrics) {
		
		this.id = id;
		this.filename = filename;
		this.title = title;
		this.interpret = interpret;
		this.year = year;
		this.rating = rating;
		this.tags = tags;
		this.length = length;
		this.registrationDate = registrationDate;
		this.lastPlayed = lastPlayed;
		this.numberOfPlayings = numberOfPlayings;
		this.annotations = annotations;
		this.language = language;
		this.category = category;
		this.lyrics = lyrics;
	}


	
	/**
	 * Returns the id of the song.
	 * @return The id of the song.
	 */
	public long getId() {
		return id;
	}


	/**
	 * Returns the file name of the song.
	 * @return The file name.
	 */
	public String getFilename() {
		return filename;
	}


	/**
	 * Returns the title of the song.
	 * @return The title of the Song.
	 */
	public String getTitle() {
		return title;
	}


	/**
	 * Returns the interpret of the Song.
	 * @return The interpret of the Song.
	 */
	public String getInterpret() {
		return interpret;
	}


	/**
	 * Returns the year of the Song.
	 * @return The year of the Song.
	 */
	public int getYear() {
		return year;
	}


	/**
	 * Returns the rating of the Song.
	 * @return The rating of the Song. 
	 */
	public double getRating() {
		return rating;
	}


	/**
	 * Returns the tags of the Song.
	 * @return The tags of the Song.
	 */
	public String[] getTags() {
		return tags;
	}
	
	
	/**
	 * Returns the tags of the Song as a string.
	 * @return The tags of the Song as a string.
	 */
	public String getTagsString() {
		
		String re = "";
		
		for( int i=0; i < tags.length; i++) {
			re += tags[i];
			if( i < (tags.length-1)) {
				re += ", ";
			}
		}
		
		return re;
	
	}


	/**
	 * Returns the length of the Song.
	 * @return The length of the Song.
	 */
	public int getLength() {
		return length;
	}
	
	
	/**
	 * Returns the registration date of the Song.
	 * @return The registration date of the Song.
	 */
	public Date getRegistrationDate() {
		return registrationDate;
	}


	/**
	 * Returns the registration date of the Song as a string.
	 * @return The registration date of the Song as a string.
	 */
	public String getRegistrationDateString() {
		return registrationDate.getDate();
	}

	
	/**
	 * Returns the date which specifies when the song was last played.
	 * @return The date when the song was last played.
	 */
	public Date getLastPlayed() {
		return lastPlayed;
	}
		

	/**
	 * Returns the date when the song was last played.
	 * @return The date when the song was last played.
	 */
	public String getLastPlayedString() {
		
		if( lastPlayed == null) {
			return "0";
		}
		
		return lastPlayed.getDate();
	}


	/**
	 * Returns the number of playings of the song.
	 * @return The number of playings of the song.
	 */
	public int getNumberOfPlayings() {
		return numberOfPlayings;
	}


	/**
	 * Returns the annotations of the song.
	 * @return The annotations of the song.
	 */
	public String getAnnotations() {
		return annotations;
	}


	/**
	 * Returns the language of the song.
	 * @return The language of the song.
	 */
	public String getLanguage() {
		return language;
	}


	/**
	 * Returns the category of the song.
	 * @return The category of the song.
	 */
	public String getCategory() {
		return category;
	}
	
	
	/**
	 * Sets the category of a song.
	 * @param category The category of the song.
	 */
	public void setCategory( String category) {
		this.category = category;
	}


	/**
	 * Returns the lyrics of the song.
	 * @return The lyrics of the song.
	 */
	public StringBuffer getLyrics() {
		return lyrics;
	}
		
	
}